#ifndef TWITWAR_CONTEXTTABWIDGET_H
#define TWITWAR_CONTEXTTABWIDGET_H

#include <QPushButton>
#include <QLabel>
#include "IContext.h"

namespace TWCore
{
	class ContextTab: public QPushButton
	{
		Q_OBJECT
		public:
			explicit ContextTab(QWidget*);
			void setContexts(QList<IContext*>);

			QLabel	countLabel;
			QList<IContext*> contexts;
	};

	class ContextTabWidget : public QWidget
	{
		Q_OBJECT
		public:
			ContextTabWidget();
			~ContextTabWidget();

			void resizeEvent(QResizeEvent*);

			void setWarning(IContext* c, const QString&);

			void addContext(IContext*);
			void setContextCountInTab(int);

			void setContextList(const QList<IContext*>&);
			QList<IContext*> getContextList();
		signals:
			void addNewContext();
			void removeContext(IContext*);
			void contextRearranged(const QList<IContext*>&);
			void switchToContexts(QList<IContext*>);
		private slots:
			void tabClicked();
		private:
			QWidget tabParent;
			QPushButton addTabButton;
			int maxContextCount;
			QList<ContextTab*> tabs;

			int m_btnIconSize;
			int i_switcherSpacing;
			int i_switcherMarginY;

			void updateTab(int index = -1);
			void checkTab(ContextTab*);
	};
}
#endif // CONTEXTTABWIDGET_H
